package _base0to1;

import java.util.List;

/**
 * 422. 有效的单词方块
 */
public class No422 {
    public boolean validWordSquare(List<String> words) {
        int n = words.size();
        for (int i = 0; i < n; i++) {
            String s1 = words.get(i);
            int m = s1.length();
            if (m > n) return false;
            for (int j = 0; j < m; j++) {
                String s2 = words.get(j);
                if (s2.length() <= i || s1.charAt(j) != s2.charAt(i)) return false;
            }
        }
        return true;
    }
}
